# -*- coding: utf-8 -*-

# 获取客户端引擎API模块
import mod.client.extraClientApi as clientApi

# 获取客户端system的基类ClientSystem
ClientSystem = clientApi.GetClientSystemCls()

class TutorialClientSystem(ClientSystem):

    # 客户端System的初始化函数
    def __init__(self, namespace, systemName):
        # 首先初始化TutorialClientSystem的基类ClientSystem
        super(TutorialClientSystem, self).__init__(namespace, systemName)
        print "==== TutorialClientSystem Init ===="
        print "【玩家ID】" + clientApi.GetLocalPlayerId()
        self.ListenEvent()

    # 监听函数，用于定义和监听函数。函数名称除了强调的其他都是自取的，这个函数也是。
    def ListenEvent(self):
        self.ListenForEvent(clientApi.GetEngineNamespace(),
                            clientApi.GetEngineSystemName(), "OnLocalPlayerStopLoading", self,
                            self.OnLocalPlayerStopLoading)

    # 函数名为Destroy才会被调用，在这个System被引擎回收的时候会调这个函数来销毁一些内容
    def Destroy(self):
        print "===== TutorialServerSystem Destroy ====="
        # 调用上面的反监听函数来销毁
        self.UnListenEvent()

    def UnListenEvent(self):
        self.UnListenForEvent(clientApi.GetEngineNamespace(),
                            clientApi.GetEngineSystemName(), "OnLocalPlayerStopLoading", self,
                            self.OnLocalPlayerStopLoading)

    def OnLocalPlayerStopLoading(self,args):
        print "===== 出生点地形加载完成时触发 ====="